
<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.users.User,
                com.scalar.chiptrack.users.UserGroup,
                com.scalar.chiptrack.commons.SessionKeys,
                 com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<chiptrack:checkLogon sourcePage="/jsp/admin/admin.jsp"/>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>

<script>
function selectVendor(){
	document.adapterSettingForm.action='<%=chipTracContext%>/adapterSetting.do?action=vendor';
	document.adapterSettingForm.submit();
}

// Function to validate the fields in jsp. Returns all the required fields if they are empt in one spree.
function validate(){
	var value = true;
	var user_id	   =	document.adapterSettingForm.userId.value;
	var pass_code  =	document.adapterSettingForm.passWord.value;
	var out_put    =    document.adapterSettingForm.outPutDirectory.value;
	if ((user_id =='')&&(pass_code=='')&&(out_put=='')){
		value="all";
		return value;
	}
	else if ((user_id !='')&&(pass_code=='')&&(out_put=='')){
		value = "pass_out";
		return value;
	}
	else if( (user_id !='')&&(pass_code!='')&&(out_put=='')){
		value = "out";
		return value;
	}
	else if ((user_id =='')&&(pass_code!='')&&(out_put=='')){
		value = "user_out";
		return value;
	}
	else if ((user_id =='')&&(pass_code!='')&&(out_put!='')){
		value = "user";
		return value;
	}
	else if ((user_id =='')&&(pass_code=='')&&(out_put!='')){
		value= "user_pass";
		return value;
	}
	else if ((user_id !='')&&(pass_code=='')&&(out_put!='')){
		value ="pass";
		return value;
	}
	else 
		return value;
}


function save()
{
	var pa=document.getElementById("message");
	
	if (validate()!=true){
		
		if (validate() == "all"){
			pa.innerHTML = "Please enter UserId, Pass Code and Out put Directory";
			return;
		}
		else if (validate() == "user"){
			pa.innerHTML = "Please enter UserId";
			return;
		}
		else if (validate() == "pass"){
			pa.innerHTML = "Please enter Pass Code";
			return;
		}
		else if (validate() == "out"){
			pa.innerHTML = "Please enter Out put Directory";
			return;
		}
		else if (validate() == "user_pass"){
			pa.innerHTML = "Please enter UserId and Pass Code";
			return;
		}
		else if(validate() == "user_out"){
			pa.innerHTML = "Please enter UserId and Out put Directory";
			return;
		}
		else if(validate() == "pass_out"){
			pa.innerHTML = "Please enter Pass Code and Out put Directory";
			return;
		}
	}

	
	/*if(freq == ''){
		pa.innerHTML = "Please enter Frequency ..";
		document.adapterSettingForm.frequency.select();
		document.adapterSettingForm.frequency.focus();
		return;
	}

	if(freq!='') {

            if (!isInteger(freq)){
		pa.innerHTML = "Please enter valid frequency,Frequency must be in hrs...";
		document.adapterSettingForm.frequency.select();
		document.adapterSettingForm.frequency.focus();
		return;
            }
        }*/
    else{
		document.adapterSettingForm.action='<%=chipTracContext%>/adapterSetting.do?action=save';
		document.adapterSettingForm.submit();
	}

}

</script>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/admin/admin_menu.jsp" %>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->
<html:form name="adapterSettingForm" method="post" action="/adapterSetting.do"    type="com.scalar.chiptrack.users.forms.AdapterSettingForm">
<center><span class="NArialW">Adaptor Settings Information</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
<center>
<strong><font face="Verdana" size="-5" align="center" color="#ff0000" id="message"></font>
</center>
<%String message = (String)request.getAttribute("ErrMsg");
   if(message==null)
   message="";

if(!message.equals("")){ %>
	<center> <strong><font face="Verdana" size="-5" align="center" color="#ff0000"><b><%=message%></b></font></center>
   <% } %>


<table border="0" width="90%" align="right" >
    <tr>
	<td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
	<tr>
	<tr><td colspan='5'><chiptrack:errors styleClass='NArialL'/></td></tr>
	<tr><td colspan='5'><chiptrack:info styleClass='NArialL'/></td></tr>

	<td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
      <td width="15%"><font class="NArialL">Vendor Name:</font></td>
	  <td width="20%"><font class="NArialL">
      	<html:select name="adapterSettingForm" property="locationId" styleClass="txfield" onchange="selectVendor()">
		<html:option value="0">Select Vendor</html:option>
        <html:options collection="vendorList" property="value" labelProperty="label"/>
        </html:select>
		</font></td>
	  <td width="15%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>	
	  <td width="20%">&nbsp;</td>
	  <td width="5%"><font class="NArialL">&nbsp;</font></td>
    </tr>
	
	<% String action = (String)request.getAttribute("action");
	    if(action==null)
		action="";%>
	<% if(action.equals("")){ %>
		<tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
		<tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
		<tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
		<!--Bhaskar commented this link and added the one below on 22 oct 2003-->
		<!--tr><td colspan=3 align=center><a href="#"onclick="top.history.back(1);"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/back.gif" width="43" height="17"></a></td></tr-->
		<tr><td colspan=3 align=center><a href="<%=chipTracContext%>/adapterSetup.do"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/back.gif" width="43" height="17" onMouseOver="window.status='Click to go Back';return true" onMouseout="window.status='';return true" title="Click here to go Back"></a></td></tr>
		<%}%>
	<% if(action.equals("vendor") || action.equals("save")){ %>

    <tr>
	<td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
   	<tr>
	<td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

   
    <tr>
      <td width="15%"><font class="NArialL">User ID:</font></td>
      <td width="20%"><font class="NArialL">
      	<html:text name="adapterSettingForm"  property="userId" size="20" styleClass="txfield" /></font></td>
	  <td width="15%"><font class="NArialL">Password:</font></td>
      <td width="20%"><font class="NArialL">
	<html:text name="adapterSettingForm"  property="passWord" size="20" styleClass="txfield" /></font></td>
    <td width="5%"><font class="NArialL">&nbsp;</font></td>
	</tr>
    <tr>
      <td width="15%"><font class="NArialL">Customer ID:</font></td>
      <td width="20%"><font class="NArialL">
      	<html:text name="adapterSettingForm"  property="acctNo" size="20" styleClass="txfield" /></font></td>
      <td width="15%"><font class="NArialL">Adaptor Out put : Directory</font></td>
	  <td width="20%"><font class="NArialL">
      	<html:text name="adapterSettingForm"  property="outPutDirectory" size="20" styleClass="txfield" /></font></td>
	  <td width="5%"><font class="NArialL">&nbsp;</font></td>
<!--
      <td width="15%"><font class="NArialL">Frequency (in Hrs):</font></td>
      <td width="20%"><font class="NArialL">
      	<html:text name="adapterSettingForm"  property="frequency" size="20" styleClass="txfield" /></font></td>
-->
    </tr>
<!--
	<tr>
      <td width="15%"><font class="NArialL">Job Name:</font></td>
      <td width="20%"><font class="NArialL">
      	<html:text name="adapterSettingForm"  property="jobName" size="20" styleClass="txfield" /></font></td>
		<td width="5%"><font class="NArialL">&nbsp;</font></td>
      <td width="15%"><font class="NArialL">Job Handler:</font></td>
      <td width="20%"><font class="NArialL">
      	<html:text name="adapterSettingForm"  property="jobHandler" size="40" styleClass="txfield" maxlength="70"/></font></td>
    </tr>

<tr>
      <td width="15%"><font class="NArialL">Adapter Out put : Directory</font></td>
      <td width="20%"><font class="NArialL">
      	<html:text name="adapterSettingForm"  property="outPutDirectory" size="20" styleClass="txfield" /></font></td>
		<td width="5%"><font class="NArialL">&nbsp;</font></td>
      <td width="15%"><font class="NArialL">&nbsp;</font></td>
      <td width="20%"><font class="NArialL">&nbsp;</font></td>
    </tr>
-->	
	<tr>
	<td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
    </tr>

	<tr>
	<td width="15%"><font class="NArialL">Same for all the 
	<bean:write name="adapterSettingForm" property="vendorName"/> locations:</font></td>
	<td width="20%"><html:checkbox name="adapterSettingForm"  property="same" styleClass="txfield" value="y"/></td>
    </tr>

    <tr>
	<td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
    </tr>
	
    <tr>
      <td colspan=2 align=center><a href="#"onclick="top.history.back(1);"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/back.gif" width="43" height="17" onMouseOver="window.status='Click to go Back';return true" onMouseout="window.status='';return true" title="Click here to go Back"></a></td>
	  <td colspan=1 align=left><a href="javascript:save()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onMouseOver="window.status='Click to Save Adapter Information';return true" onMouseout="window.status='';return true" title="Click here to Save Adapter Information"></a></td>
    </tr>
	
	<%}%>
	<html:hidden name="adapterSettingForm" property="jobId" />
	<html:hidden name="adapterSettingForm" property="vendorName" />
	</table>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</html:form>
</BODY>
</HTML>
